Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnf clean: Do not report an error on a nonexistent cache directory #1707

Conversation

ppisar
Copy link
Contributor

@ppisar ppisar commented Sep 18, 2024

If /var/cache/libdnf5 directory did not exist, "dnf clean all" reported and error:

Cannot iterate the cache directory: "/var/cache/libdnf5"

This patch optimizes this case to no operation. If there is no cache, there is nothing to remove.

If the iterator fails for a different reason, the message is ammended with an operating system error message, explaining the cause.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2313032

return;
}
throw std::runtime_error(libdnf5::utils::sformat(
_("Cannot iterate the cache directory: \"{}\": {}"), cachedir.string(), ec.message()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nitpicking - how about removing the first colon from the message: _("Cannot iterate the cache directory \"{}\": {}"). It seems redundant to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the message.

@ppisar ppisar force-pushed the dnf_clean_to_ignore_missing_directory branch from 4ba7211 to 1e8e10e Compare September 18, 2024 13:15
If /var/cache/libdnf5 directory did not exist, "dnf clean all"
reported and error:

    Cannot iterate the cache directory: "/var/cache/libdnf5"

This patch optimizes this case to no operation. If there is no cache,
there is nothing to remove.

If the iterator fails for a different reason, the message is ammended
with an operating system error message, explaining the cause.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2313032
@ppisar ppisar force-pushed the dnf_clean_to_ignore_missing_directory branch from 1e8e10e to 39213e6 Compare September 18, 2024 13:27
Copy link
Member

@m-blaha m-blaha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ppisar ppisar added this pull request to the merge queue Sep 19, 2024
Merged via the queue into rpm-software-management:main with commit 117bc3e Sep 19, 2024
14 of 20 checks passed
@ppisar ppisar deleted the dnf_clean_to_ignore_missing_directory branch September 19, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants